<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>

		<link rel="stylesheet" href="${pageContext.request.contextPath }/resources/css/ace/bootstrap-datetimepicker.min.css" />
		<style>
			*{
				margin: 0;
				padding: 0;
			}
			.box{
				max-width:100%;
				margin: 5px 5px;
			}
			.box table{
				width:100%;
				color: #666;
			}
			.box table tr th{
				border-top:2px solid #d3d3d3;
				border-bottom:2px solid #d3d3d3;
				border-left:2px solid #d3d3d3;
				height:30px;
				text-align: center;
				background: #00A0E9;
				color: #ffffff;
			}
			.box table tr th:first-child{
				width:120px;
				text-align: center;
			}
			.box table tr th:last-child{
				border-right:2px solid #d3d3d3;
			}
			.box table tr td{
				border-bottom:2px solid #d3d3d3;
				border-left:2px solid #d3d3d3;
				height:30px;
				text-align: center;
				font-weight: bold;
				line-height: 30px;
				padding: 0 0;
			}
			.box table tr td:first-child{
				background: #00A0E9;
				color: #ffffff;
			}
			.box table tr td:last-child{
				border-right:2px solid #d3d3d3;
			}
			.box table tr td:hover{
				cursor:pointer;
			}
			.bghalf{
				background: url(${pageContext.request.contextPath }/resources/images/red.jpg) no-repeat;
				background-size:100% 50% ;
			}
			.bgall{
				background: url(${pageContext.request.contextPath }/resources/images/red.jpg) no-repeat;
				background-size:100%
			}
			.rq{
				width:500px;
				float: right;
				margin:10px 0;
			}
			.rq .buttn{
				width:150px;
				float: right;
			}
			.prev{
				visibility: hidden !important;
			}
			.next{
				visibility: hidden !important;
			}
			.today{
				visibility: hidden !important;
			}
			.breadcrumb .active::before{content:">";}
		</style>
		<script type="text/javascript" src="${pageContext.request.contextPath }/resources/js/bootstrap/bootstrap.min.js" ></script>
		<script type="text/javascript" src="${pageContext.request.contextPath }/resources/js/bootstrap/bootstrap-datetimepicker.js" ></script>
		

<div class="input-group" style="float:right;border-radius:5px">
   	<input type="text" class="form-control form_datetime_2" readonly id="month_time" value="" placeholder="选择月份"  />
</div>
<div class="row" style="margin-top:5px;">
	<div class="col-xs-12 widget-container-col ui-sortable"
		style="min-height: 127px;">
		<!-- #section:custom/widget-box.options.transparent -->
		<div class="widget-box transparent ui-sortable-handle"
			style="opacity: 1; z-index: 0;">
			<div class="widget-header">
				<h4 class="widget-title lighter">广告排期</h4>
				<div class="widget-toolbar no-border">
					<a href="#" data-action="fullscreen" class="orange2"> 
						<i class="ace-icon fa fa-arrows-alt"></i>
					</a> 
					<a href="#" data-action="collapse" class="green"> 
						<i class="ace-icon fa fa-chevron-up"></i>
					</a>
				</div>
			</div>


<div class="box">

	</div>


			
<script type="text/javascript">
			$(".form_datetime_2").
			    datetimepicker({
			        language:  'zh',
			        format: 'yyyy-mm',
			        autoclose: true,
			        todayBtn: true,
			        startView: 'year',
			        minView:'year',
			        maxView:'decade'

			});
		
			function submitmonth(year,mon){
				var params={};
				params["year"]=year;
				params["month"]=mon;
				$.ajax({
					type:"post",
					url:sys.rootPath +"/adarrange/querymonth.html",
					data:params,
					dataType:"json", 
					success:function(data){
						$(".box").html("<table id='adarrangetb' cellpadding='0' cellspacing='0'><tr id='first'><th>广告位/日期</th></tr></table>");
						var flag=0;
						for(var i in data){
							if(flag==0){
								for(var j=1;j<=data[i].length;j++ ){
									if(j<10) j="0"+j;
									$("#first").append("<th>"+j+"</th>");
								}
								flag=1;
							}
							$("#adarrangetb").append("<tr id='"+i+"'><td>"+i+"</td></tr>");
							for(var j=0;j<data[i].length;j++ ){
								$("#"+i).append("<td day='"+j+"' "+data[i][j]+" onclick='readysub(this)' ></td>");
							}
							
						}
					},
					error:function(data){
						alert(data+"fail");
					}
				});
			}
			$(".form_datetime_2").on("changeMonth",function(e){
				submitmonth(e.date.getFullYear(),e.date.getMonth());
				$(".lighter").text(e.date.getFullYear()+"年"+parseInt(e.date.getMonth()+1)+"月广告排期");
			});
			var date=new Date();
			submitmonth(date.getFullYear(),date.getMonth());
			$(".lighter").text(date.getFullYear()+"年"+parseInt(date.getMonth()+1)+"月广告排期");
			function readysub(obj){
				var $this=$(obj);
				var year=$(".lighter").text().substr(0,4);
				var monthstart=$(".lighter").text().indexOf("年");
				var monthend=$(".lighter").text().indexOf("月");
				if((monthend-monthstart)==2){
					var month="0"+$(".lighter").text().charAt(5);
				}else{
					var month=$(".lighter").text().charAt(5)+$(".lighter").text().charAt(6);
				}
				var days=parseInt($this.attr("day"))+1;
				if(days<10){
					var dates1=year+"-"+month+"-0"+days;
				}else{
					var dates1=year+"-"+month+"-"+days;
				}
				var code=$this.attr("code");
				
				webside.common.loadPage( '/adrelease/listUI.html?date='+dates1+'&code='+code);
			}
			$(".navbar-fixed-top").css("background","#438eb9");
			$(".navbar-fixed-top").find("small").css("color","#fff");
</script>

